package com.ruoyi.system.config;

import com.doudian.open.api.order_addOrderRemark.OrderAddOrderRemarkRequest;
import com.doudian.open.api.order_addOrderRemark.OrderAddOrderRemarkResponse;
import com.doudian.open.api.order_addOrderRemark.param.OrderAddOrderRemarkParam;
import com.doudian.open.api.order_logisticsAdd.OrderLogisticsAddRequest;
import com.doudian.open.api.order_logisticsAdd.OrderLogisticsAddResponse;
import com.doudian.open.api.order_logisticsAdd.param.OrderLogisticsAddParam;
import com.doudian.open.api.order_review.OrderReviewRequest;
import com.doudian.open.api.order_review.OrderReviewResponse;
import com.doudian.open.api.order_review.param.OrderReviewParam;
import com.doudian.open.core.AccessToken;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


@Slf4j
@Component
public class DouDianAPI {


    public static OrderReviewResponse review(String successTag, String douDianOrderId, AccessToken token) {
        OrderReviewRequest request = new OrderReviewRequest();
        OrderReviewParam param = request.getParam();
        param.setObjectId(douDianOrderId);
        param.setTaskType(3001L);
        if ("200".equals(successTag)) {
            param.setRejectCode(0L);
        } else {
            param.setRejectCode(200005L);
        }
        OrderReviewResponse response = request.execute(token);
        return response;
    }


    public static void addOrderRemark(String douDianOrderId, String phone, AccessToken token) {
        OrderAddOrderRemarkRequest request = new OrderAddOrderRemarkRequest();
        OrderAddOrderRemarkParam param = request.getParam();
        param.setOrderId(douDianOrderId);
        param.setRemark(phone);
        param.setIsAddStar("true");
        param.setStar("4");
        OrderAddOrderRemarkResponse response = request.execute(token);
    }


    public static OrderLogisticsAddResponse logisticsAdd(String douDianId, AccessToken token) {
        OrderLogisticsAddRequest request = new OrderLogisticsAddRequest();
        OrderLogisticsAddParam param = request.getParam();
        param.setOrderId(douDianId);
        param.setCompanyCode("qita");
        OrderLogisticsAddResponse response = request.execute(token);
        log.info(response.toString());
        return response;
    }


}
